package lesson2;

public class Demo1 {
    public static void main(String[] args) {
        String str1 = "hello";
        String str2 = " world!!!";
        String str3 = "hello world!!!";
        //String str4 = str1+str2;
        String str4 = (new StringBuilder().append("hello").append(" world!!!")).toString();
        //String str5 = "hello"+" world!!!";
        String str5 = "hello world!!!";
        System.out.println(str3 == str4);
        System.out.println(str3 == str5);
        System.out.println(str4 == str5);
        //2 fasle true  ?
        //3
        //4
        //5 false true true
        //6
        //7
        //8
        //9 false true ?
        //10 false true false
        //11 false true false
        //12
        //13 false true false
        //14 false true false
        //15 false true false
        //16 false true false
        String str222 = "abc";
        String str22 = new String("abc");
        //String会有一个字符串常量池
        //如果常量池中没有，则先放入常量池，再创建对象
        //如果有，直接根据常量池内容创建对象
        //1  1
        //2  ?
        //3  1
        //4  2
        //5  2
        //6  2
        //7  2
        //8  2
        //9  2
        //10 ?
        //11 2
        //12 2
        //13 2
        //14 2
        //15 2
        //16 2
    }
}
